<?php

namespace app\api\validate;

use app\common\tool\WeChat\WeChat;
use think\Validate;

class UserVideoComment extends Validate
{
    protected $rule = [
        "id"           => "require",
        "comment"      => "require|msgSecCheck",
        "video_second" => ">=:0",
    ];

    protected $message = [
        'id.require'         => '视频id不能为空',
        'comment.require'    => '请填写评论内容',
        'comment.msgSecCheck' => '评论内容涉嫌违规，请文明评论',
        'video_second'       => '视频已播放秒数需大于等于0',
    ];

    protected function msgSecCheck($value): bool
    {
        $err = (new WeChat())->msgSecCheck($value);
        if(isset($err['errcode']) && $err['errcode'] != 0){
            return false;
        }

        return true;
    }
}